import Vue from 'vue'
import App from './App.vue'
import Mint from 'mint-ui';
import router from './router'
import store from './store'
import axios from "axios";
import CryptoJS from "crypto-js";
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import './permission'
import VueJsonp from 'vue-jsonp'
Vue.use(VueJsonp)
Vue.use(Mint);
Vue.use(ElementUI);
import vueResource from "vue-resource"
Vue.use(vueResource)
import global_ from './utils/global';
Vue.prototype.GLOBAL = global_;

import echarts from 'echarts'
Vue.prototype.$echarts = echarts

import { Loadmore, Search, Toast, MessageBox, Indicator } from 'mint-ui';
Vue.component(Loadmore.name, Loadmore);
Vue.component(Search.name, Search);
window.Toast = Toast;
window.MessageBox = MessageBox;
window.Indicator = Indicator;
Vue.config.productionTip = false

// import VConsole from 'vconsole'
// let vConsole = new VConsole()
// Vue.use(vConsole)

router.beforeEach(function (to, from, next) {
    console.log(to.path, "11122")
    var token = localStorage.getItem("token");
    window.scrollTo(0, 0)
    if (!token && (to.path !== '/login' && to.path !== '/index' && to.path !== '/register')) {
        console.log(token, to.path)
        next('/login');
    } else {
        next();
    }

})

new Vue({
    router,
    store,
    render: h => h(App),
}).$mount('#app')
